package com.leoman.message.handers;

import com.leoman.core.Constant;
import com.leoman.core.UrlManage;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.cp.api.WxCpMessageHandler;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;

import java.util.Map;

/**
 * Created by wangbin on 2015/8/6.
 */
public class NumberMessageHandler implements WxCpMessageHandler {

    @Override
    public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
        if (wxMessage.getContent().equals("1")) {
            String text = "很高兴为您服务: \n";
            String aTag = "<a href=\"" + UrlManage.getProUrl("weixin/business/in") + "\">认证链接</a>";
            return WxCpXmlOutMessage.TEXT().content(text + aTag).fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName()).build();
        } else {
            return WxCpXmlOutMessage.TEXT().content(Constant.MSG_DEF_TEXT).fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName()).build();

        }
    }
}
